package com.usb.serial.device.settingIp;

import static android.content.Context.MODE_PRIVATE;


import android.content.Context;
import android.content.SharedPreferences;

public class Url {

    public static Context context;

    private static String[] IP = {"0", "0", "0", "0", "0"};

    public static void setIp(String IP, int position) {
        SharedPreferences sharedPreferences = context.getSharedPreferences("Url.txt", MODE_PRIVATE);
        SharedPreferences.Editor editor = sharedPreferences.edit();
        editor.putString("ip" + position, IP);
        editor.apply();
        Url.IP[position] = IP;
    }

    public static String[] getIP() {
        SharedPreferences sharedPreferences = context.getSharedPreferences("Url.txt", MODE_PRIVATE);
        IP[0] = sharedPreferences.getString("ip0", "0");
        IP[1] = sharedPreferences.getString("ip1", "0");
        IP[2] = sharedPreferences.getString("ip2", "0");
        IP[3] = sharedPreferences.getString("ip3", "0");
        IP[4] = sharedPreferences.getString("ip4", "0");
        return Url.IP;
    }



}
